// Child31.jsx 组件之间传值-子组件
import { Component } from 'react'
import '../assets/css/Child.css'
import event from '../utils/bus'

export default class Child31 extends Component {
  state = {
    c01Data: '子组件01数据'
  }

  sendData () {
    // 通过消息总线发送数据
    event.emit('my-event', this.state.c01Data)
  }
  render () {
    return (
      <div className='child-container'>
        <h3>子组件01</h3>
        <p>当前组件数据：{this.state.c01Data}</p>
        <button onClick={this.sendData.bind(this)}>发送数据给其他组件</button>
      </div>
    )
  }
}
